package com.ruoyi.develop.invoice.utils;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.develop.invoice.entity.Invoice;
import com.ruoyi.develop.invoice.entity.NewInvoice;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Test {




    // main方法 入口 测试pdf文件发票 识别
    public static void main(String[] args) {
        String path = "C:\\Users\\44150\\Desktop\\temp\\fapiao.pdf";
        // 构造文件保存路径（文件名使用原始文件名，防止重名可以添加UUID等）
        Path targetLocation = Paths.get(path);
        // 保存文件
        NewInvoice newInvoice = NewInvoiceExtractor.newPdfProcessInvoicesInFile(targetLocation.toAbsolutePath().toString());
        if (StringUtils.isNotBlank(newInvoice.getNumber())) {//新版发票
            System.out.println(newInvoice.getNumber());
            System.out.println(newInvoice.getContent());
            System.out.println(newInvoice.getSellerName());
            System.out.println(newInvoice.getDate());
            System.out.println(newInvoice.getAmount());
            System.out.println(newInvoice.getTaxAmount());
            System.out.println(newInvoice.getTotalAmount());
            System.out.println(newInvoice.getInReserve2());
        } else {//老版发票
            Invoice invoice = InvoiceExtractor.newPdfProcessInvoicesInFile(targetLocation.toAbsolutePath().toString());
            System.out.println(invoice.getNumber());
            System.out.println(invoice.getContent());
            System.out.println(invoice.getCode());
            System.out.println(invoice.getSellerName());
            System.out.println(invoice.getDate());
            System.out.println(invoice.getAmount());
            System.out.println(invoice.getTaxAmount());
            System.out.println(invoice.getTotalAmount());
            System.out.println(invoice.getInReserve2());
        }

    }


}
